<?php
namespace app\base\controller;


use app\base\library\Auth;
use CMaker\Component;
use think\Controller;
use think\facade\Session;
use app\Base\model\Menu;
use Tree\Tree;
use app\base\model\AdminLog;

class  Common extends Controller
{

    protected static $role;
    protected $admin_menu;

    //初始化
    protected function initialize()
    {


        $is_login = Session::get('manager_login');
        if($is_login !== 'pass'){
            $this->redirect(url('login/in'));
        }

        self::$role = Session::get('role');

        $auth = new Auth();

        //检查对应的权限
        $flag = $auth->check_auth(self::$role);

        if(!$flag) $this->error($auth->getError());


        //记录操作日志
        try{
            AdminLog::create();
        }catch (Exception $e){
            throw new Exception('记录操作日志失败');
        }

    }


}